<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>   
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>  
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>       
<c:set var="ctx" value="${pageContext.request.contextPath}"/> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<jsp:include page="../include.jsp"/>
<script type="text/javascript">
	
	$(function() {
		parent.$.messager.progress('close');
		$('#form').form({
			url : '${ctx}/sysConfig/add.do',
			onSubmit : function() {
				validate = $(this).form('validate');
				codeExit = checkExist();	
				if(validate && !codeExit){
					return true;
				}else{
					return false;
				}				
			},
			success : function(result) {
				parent.$.messager.progress('close');
				result = $.parseJSON(result);
				if(result.success) {
					parent.$.modalDialog.openner_dataGrid.datagrid('load');
					parent.$.modalDialog.handler.dialog('close');
					parent.$.messager.alert('系统提示', result.msg, 'info');
				} else {
					parent.$.messager.alert('错误', result.msg, 'error');
				}
			}
		});
	});
	
	function checkExist(){	
		var codeExit;
		var configCode = $("#configCode").val();
		if(configCode == ''){
			return ;
		}			
		$.ajax({
			type: "POST",
			url: '${ctx}/sysConfig/checkExist.do',
			dataType:"json",
			async:false,
			data:{
				configCode : configCode
			},
			success: function(result) {	 
				if(result.success == true) {
					codeExit = result.data;
					if(codeExit){
						$('#codeTip').html(result.msg);
					}
 				} else {					
 					//校验失败
 					codeExit = true;
 				}				
			}
		});
		return codeExit;
	}
	
	function clearValue(){
		var codeTip = $('#codeTip').html();
		if(codeTip != '') 
		{
			$('#codeTip').html('');			
		}			
	}
</script>
</head>
<body>
	<div class="easyui-layout" data-options="fit:true,border:false">
		<div data-options="region:'center',border:false" title="" style="overflow: hidden;">			
			<form id="form" method="post">
				<input name="moduleId" type="hidden" value="${moduleId}">	
	            <div style="margin-bottom:15px;padding-top:10px;padding-left:30px">
	                <input class="easyui-textbox" name="configName" style="width:80%" data-options="label:'配置名称:',required:true">
	            </div>
	            <div style="margin-bottom:15px;padding-left:5px">
	                <input id="configCode" class="easyui-textbox" name="configCode" style="width:80%" data-options="label:'配置编码:',required:true" onfocus="clearValue();">	               
	            </div>
	            <div style="margin-bottom:5px;padding-left:100px">
	                <span id="codeTip" style="color: red"></span>
	            </div>
	            <div style="margin-bottom:15px;padding-left:5px">
	               <input class="easyui-datetimebox" name="gooffTime" labelWidth="70px" data-options="label:'启运时间:',required:true"labelPosition="left" style="width:28%;height:22px;">
	            </div>
	            <div style="margin-bottom:15px;padding-left:5px">
	                <input class="easyui-textbox" name="configDescr" style="width:80%;height:60px" data-options="label:'配置描述:',multiline:true">
	            </div>	           
	        </form>
		</div>
	</div>
</body>
</html>